define(["jquery"],function (jq) {
    return {
        commPost(url,data,callback,ecallback,accessToken){
            jq.ajax({
                headers:{accessToken: accessToken},
                type: 'POST',
                url:url,
                data:JSON.stringify(data),
                dataType:"json",
                contentType:"application/json",
                cache: false,
                success:function(data){
                    if(callback){

                        callback(data);
                    }
                },
                error:ecallback||myerror
            });

        },
        commGet(url,data,callback,ecallback,accessToken){
            jq.ajax({
                headers:{accessToken: accessToken},
                type: 'GET',
                url:url,
                data:data,
                dataType:"json",
                contentType:"application/json",
                cache: false,
                success:function(data){
                    if(callback){
                        callback(data);
                    }
                },
                error:ecallback||myerror
            });

        },
        commDel(url,data,callback,ecallback,accessToken){
            jq.ajax({
                headers:{accessToken: accessToken},
                type: 'DELETE',
                url:url,
                data:data,
                dataType:"json",
                contentType:"application/json",
                cache: false,
                success:function(data){

                    if(callback){


                        callback(data);
                    }

                },
                error:ecallback||myerror
            });

        },
        commPut(url,data,callback,ecallback,accessToken){
            jq.ajax({
                headers:{accessToken: accessToken},
                type: 'PUT',
                url:url,
                data:JSON.stringify(data),
                dataType:"json",
                contentType:"application/json",
                cache: false,
                success:function(data){

                    if(callback){

                        callback(data);
                    }


                },
                error:ecallback||myerror
            });

        },
       myerror (XMLHttpRequest, textStatus, errorThrown){
            if( olUtile!=null){
              olUtile.closeLoading();
            }
            //alert(textStatus+""+errorThrown);
            //  alert(XMLHttpRequest.readyState);
       }
    }
})
